package com.weather.controller;

import com.weather.domain.ApiRespones;
import com.weather.service.WeatherService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author: htc
 * @date: Created in 15:05 2018/4/20.
 */
@RestController
@RequestMapping("/city")
public class WeatherController {

    @Resource
    private WeatherService weatherService;

    @GetMapping("/{cityName}")
    public ApiRespones getWeather(@PathVariable("cityName") String cityName) throws IOException, ClassNotFoundException, InterruptedException {
        return weatherService.getWeather(cityName);
    }
}
